<?php
/*
 * Creative Bulletin Board Generation 3
 * Version 1.0 Beta 1
 +------------------------------------
 * Core Language Class
 * Started: September 5, 2009 08:52 AM
 * Script version: 1.0
 +------------------------------------
 */
class lang{
	public function __construct(){
		global $db;
		if(isset($_SESSION["cf_username"]) and isset($_SESSION["cf_controller"])){
			require_once(BASE_PATH."applications/universal/user/controllers/user.php"); # Dare I say - Even worse workarounds?
			$userController = unserialize($_SESSION["cf_controller"]);
			$uid = $userController->getUID();
			$lang = $db->user_conf_value($uid, "lang", "language");
		}
		else{
			$lang = $db->conf_value("language");
		}
		if(file_exists(BASE_PATH."lang/{$lang}.php")){
			require_once(BASE_PATH."lang/{$lang}.php");
			$this->langArray = $languageArray;
			$this->langInfo = $languageInfo;
		}
		else{
			trigger_error("Language pack selected ($lang) was not found");
		}
	}
	
	public function getByKey($key){
		if(isset($this->langArray[$key])){
			return $this->langArray[$key];
		}
		else{
			trigger_error("Language variable {$key} was not found");
		}
	}
	
	public function langCopy(){
		if($this->langInfo['showcopy'] !== false)
			return "<b>{$this->getByKey('core.languagepack')}:</b> ".$this->langInfo['copyright']."<br />";
		else return "";
	}
}
